W7. Pushdown Computation Models
1. Theory
1.1 Recap: Finite State Transducers
Before introducing the more powerful Pushdown Transducer, it is important to recall how a Finite State Transducer (FST) works, since a PDT is its direct generalization.
A Finite State Transducer is a Finite State Automaton extended with an output mechanism. Formally, an FST is a tuple
is a standard FSA (states, input alphabet, transition function, initial state, accepting states); is the output alphabet — the set of symbols that can be written to the output; is the translation function — it maps each state-input pair to an output string.
Key remark: The translation
How an FST works: As the FST reads each input symbol, it simultaneously (a) changes state (via input/output, for example a/A means “read
Example — Simple case-converter:
Consider
The FST has a single accepting state
: read , output : read , output
On input
Example — FST with restricted domain:
Consider
(accepting): reads and outputs ; if it reads , goes to the non-accepting “sink” state (rejecting): reads any symbol and outputs (because the string will be rejected anyway)
On input
Limitation of FSTs: FSTs, like FSAs, have only fixed, finite memory (the current state). They cannot handle languages requiring counting, such as
1.2 Pushdown Transducers (PDTs)
1.2.1 Motivation and Intuition
A Pushdown Transducer (PDT) extends a Pushdown Automaton with an output tape, just as a Finite State Transducer extends an FSA. The PDT can use its stack not only to recognize the language (as in a PDA) but also to assist the translation: the stack stores intermediate information needed to generate the correct output.
The architecture of a PDT consists of four components:
- Input tape: a read-only tape from which the PDT reads symbols left-to-right
- Finite state control: a finite set of states with transition logic
- Stack: a LIFO (last-in, first-out) memory that can grow without bound
- Output tape: a write-only tape to which the PDT appends output symbols
The stack is a destructive memory: once a symbol is popped off the stack, it is gone. This is both the source of the PDT’s power and its ultimate limitation.
A transition of a PDT reads an input symbol (or
1.2.2 Transition Notation
A transition from state
where:
is the input symbol consumed (or for a silent move) is the stack symbol popped from the top is the string pushed back onto the stack (replacing ) is the string written to the output tape
An alternative notation uses a colon to separate the stack part from the output:
Both notations are used in the literature and mean the same thing.
This means that transition
1.2.3 Formal Definition
A Pushdown Transducer is a 9-tuple:
where:
— finite set of states — finite input alphabet — finite stack alphabet — the transition function (partial; maps to finite subsets) — initial state — initial stack symbol (bottom-of-stack marker) — accepting states — finite output alphabet — the translation function (defined only where is defined)
Remarks:
are the same components as in a standard “acceptor” PDA. is defined only where is defined — there is no output on undefined transitions.- The stack can be necessary for two distinct reasons: (a) the language being recognized requires it, and/or (b) the translation requires it.
1.2.4 Configurations and Transitions
A configuration of a PDT is a 4-tuple:
where:
— the current state of the finite control — the unread portion of the input string — the current contents of the stack (top symbol first) — the string already written on the output tape
Transitions between configurations:
- Input move (consuming symbol
): If and , then: -move (silent, no input consumed): If and , then:
Note the key difference: in an
1.2.5 Acceptance Condition
The PDT translates a string
This is defined analogously to how translation works in an FST: the translation of
1.3 PDT Examples
1.3.1 Translating
Consider
Strategy: Use the stack to count the
The PDT has states
: transition — read first , push onto , output : transition — read each additional , push another , output : transition — start reading ’s, pop one , output : transition — each additional , pop one , output : transition — if is on top after consuming all input, accept (no output)
On input
1.3.2 Translating
Consider
Strategy: During the push phase (reading
: and — push ’s with no output : — first , pop one , output : — each additional , output : — accept
Result:
1.3.3 Translating
Consider
Strategy: During the push phase (reading
: and — push ’s, output for each : — pop , output : — each additional , output : — accept
Result:
1.3.4 Translating (Reverse a String)
Consider
Strategy (PUSH-THEN-POP): While reading
- State
(PUSH TIME — NO OUTPUT): ; ; ; ;
- Transition
(STOP PUSH): ;
- State
(POP TIME — OUTPUT GENERATED): ;
- Transition
(accepting):
On input
This example illustrates a key property: the stack enables translations that require “remembering” the input in order to produce output in a non-left-to-right order.
1.4 Closure Properties of DPDA Languages
We now turn from transducers to a fundamental question in formal language theory: which operations preserve the class of languages recognized by Deterministic Pushdown Automata (DPDAs)?
This is the question of closure properties. A class of languages
Formally:
Motivation: For regular languages (recognized by FSAs), the class is closed under all four standard operations — union, intersection, complement, and difference. We want to know whether deterministic context-free languages (DPDAs) enjoy the same nice properties.
Spoiler (summary table):
| FSA (Regular) | yes | yes | yes | yes |
| DPDA (Det. CFL) | no | no | no | yes |
We now examine each operation in turn and understand why the result is what it is.
1.4.1 Closure Under Union: NO
Claim: DPDA is not closed under union.
Counterexample: Consider the following two languages over
Both
cannot be recognized by any DPDA.
Why? The intuitive reason is the stack preparation problem. When a DPDA reads the
More precisely: after reading
Contrast with regular languages: For FSAs, taking the union is easy — build the cross-product automaton and accept if either component accepts. For DPDAs, no analogous construction works in general because the stack contents for
1.4.2 Closure Under Intersection: NO
Claim: DPDA is not closed under intersection.
Counterexample: Consider languages over
Both are recognizable by DPDAs:
: count ’s, match ’s one-for-one, then accept any positive number of ’s. : skip any positive number of ’s, then count ’s, match ’s one-for-one.
Their intersection:
This is the classic language
Proof via complement: There is also an algebraic way to see this, using De Morgan’s law:
Since DPDA is closed under complement (see below), if it were also closed under intersection, it would be closed under union — but we just showed it is not. Contradiction.
1.4.3 Closure Under Complement: YES
Claim: DPDA is closed under complement.
Theorem: If
Why complement works for DPDA but not NPDA: For nondeterministic PDAs, complementation fails because a string might be rejected on all computation paths but accepted on some — the nondeterminism makes it hard to “flip” the acceptance condition. For deterministic PDAs, each input leads to exactly one computation, so we can cleanly distinguish accepted from rejected strings.
Construction sketch — why simply swapping final states does not work:
For FSAs, complementing is simple: swap final and non-final states. For PDAs, this naive approach fails because of
Correct construction — three steps:
- Eliminate loops: Ensure the DPDA is acyclic — it always reads the entire input string and then stops, with no
-moves possible after the last input symbol is consumed. Every DPDA can be transformed into an equivalent acyclic DPDA (this is a non-trivial but provable fact). This prevents the -move problem above. - Complete
: Make the transition function total by adding a non-accepting “garbage” state for all undefined transitions. After this, the DPDA is a total function from configurations to configurations. - Swap final and non-final states: Now that the machine always halts on a well-defined state after reading the entire input (with no
-move ambiguity), swapping accepting and non-accepting states correctly complements the language.
Why acyclicity matters: Without eliminating
1.4.4 Closure Under Difference: NO
Claim: DPDA is not closed under difference (set subtraction).
Proof by contradiction: Suppose DPDA were closed under
Since DPDA is closed under complement,
Therefore DPDA is not closed under
Comparison with regular languages: Regular languages (FSA) are closed under all four operations. Deterministic context-free languages have a more asymmetric closure profile — they are only closed under complement, but not under union, intersection, or difference.
1.5 The Bar-Hillel Lemma (Pumping Lemma for CFLs)
The Bar-Hillel Lemma is the generalization of the Pumping Lemma from regular languages to context-free languages. Just as the Pumping Lemma for regular languages gives a necessary condition for regularity, Bar-Hillel gives a necessary (but not sufficient) condition for being a context-free language.
Bar-Hillel Lemma: If
satisfying:
(the “pumped” parts are not both empty) (the pumped region is bounded) for all (pumping any number of times stays in )
Note: unlike the regular Pumping Lemma (which pumps one substring
Application — proving
The language
Assume for contradiction that
- The region
is short (length ), so it can span at most two of the three blocks ( ’s, ’s, ’s). - Pumping up (
) increases the counts of at most two symbol types, but not all three equally. - Therefore
has unequal counts of ’s, ’s, and ’s — it is not in .
Contradiction. So
1.6 The Stack as Destructive Memory and Limits of PDAs
1.6.1 Destructive vs. Persistent Memory
A key insight about PDAs is that the stack is a destructive memory: once a symbol is popped off the stack, it is irrecoverably gone. This is precisely why:
- A PDA can recognize
: push symbols while reading ’s, then pop one per . - A PDA cannot recognize
: to check the ’s, it needs to know again — but the stack was already emptied verifying the ’s.
To overcome this limitation, one needs persistent (read/write) memory — a device that can read a memory location without destroying it. This is the motivation for Turing Machines, which use an unbounded read/write tape instead of a stack.
1.6.2 The Language Hierarchy
The hierarchy of languages recognized by different computational models is:
- Regular languages ⊂ Context-free languages (CFLs) ⊂ Recursively enumerable languages (all TM-computable languages)
Examples that illustrate the boundaries:
: not regular (proved by Pumping Lemma), but context-free (recognized by a PDA) : not context-free (proved by Bar-Hillel), but computable by a Turing Machine : context-free (recognized by an NPDA) but not a deterministic context-free language
1.7 Why PDAs Are at the Heart of Compilers
PDAs are not merely theoretical constructs — they have direct, practical applications in software engineering, particularly in compiler construction.
1.7.1 PDA and Compilers
The stack memory in a PDA has a LIFO (Last-In, First-Out) policy. This is precisely the right structure for analyzing nested syntactic structures, such as:
- Arithmetic expressions with parentheses:
(a + (b * c)) - Block-structured programs with
begin/endor{/} - Function call chains with activation records (each call pushes a frame, each return pops it)
The general structure of a compiler proceeds through several phases:
- Lexical Analysis: recognizes tokens (identifiers, keywords, operators) — modeled by FSAs
- Syntax Analysis (Parsing): recognizes the grammatical structure of programs — modeled by NPDAs (context-free grammars describe most programming language syntax)
- Semantic Analysis, Code Generation, Optimization: further processing
This is why the syntax of almost all programming languages is defined by a context-free grammar, and why parsers (the software that performs syntax analysis) are essentially pushdown automata.
1.7.2 Fixed vs. Unbounded Memory
A crucial conceptual distinction separates FSAs from PDAs:
- FSA: fixed (bounded) memory — the machine has a finite number of states, period. It cannot count to an arbitrary
. - PDA: finite but unbounded memory — the machine has a finite set of states, but the stack can grow without bound. It can count to any
by pushing symbols.
For example,
1.8 Automata Theory and Models of Computation
1.8.1 What is Automata Theory?
Automata theory is the branch of theoretical computer science that studies:
- Abstract mathematical machines (automata) and their computational properties
- The computational problems that can be solved by various types of automata
The word automaton (plural: automata) comes from the Greek αὐτόματον, meaning “self-moving” — something that acts by itself. The word was first used by Homer (describing automatic door opening and self-moving statues in ancient Greek epic poetry).
1.8.2 Why Study Automata Theory?
- An automaton is a finite representation of a formal language that may be infinite — a finite machine can describe infinitely many strings.
- Automata serve as theoretical models for computing machines, enabling rigorous proofs about computability and complexity.
- They have direct practical applications: compiler design, model checking, protocol verification, pattern matching.
1.8.3 Models of Computation
A model of computation describes how outputs are computed from inputs, and how computational units, memories, and communications are organized. Different models capture different levels of computational power:
Sequential models:
- Finite State Automata (FSA) — limited expressiveness, fixed memory; suitable for pattern matching and “brute-force” analysis (model checking)
- Pushdown Automata (PDA) — adds a stack; can handle nested structures; basis for parsing
- Turing Machine — unlimited read/write tape; the most general model of sequential computation
Functional models:
- Lambda calculus — computation via function application and reduction
Concurrent models:
- Petri nets — for modeling concurrent, distributed systems
This list is not exhaustive — there are many other models (register machines, cellular automata, etc.).
1.8.4 Applications of FSAs in Practice
FSAs (Finite State Automata) have wide practical applications:
- Moore/Mealy machines model digital circuits and electronic devices
- Mealy machines are essentially finite state transducers (FSTs) — they produce output on transitions
- Lexical analysis in compilers: FSAs recognize tokens (the “words” of a programming language)
- UML state machines: the Unified Modeling Language uses FSA-based notation for describing system behavior (e.g., a temperature controller with states Idle, Heating, Cooling)
- Protocol modeling: turnstile gates, vending machines, communication protocols can all be modeled as FSAs
The key limitation of FSAs is their fixed memory: they are suitable for patterns that do not require counting or remembering unbounded amounts of data.
2. Definitions
- Finite State Transducer (FST): A finite state automaton extended with an output mechanism. A 7-tuple
where is the output alphabet and is the translation function. Translation is defined only on accepted strings. - Pushdown Transducer (PDT): A pushdown automaton extended with an output tape. A 9-tuple
where is the output alphabet and is the translation function. The stack can store information needed both for recognition and translation. - PDT Configuration: A 4-tuple
where is the current state, is the unread input, is the stack contents (top first), and is the output already written. - Translation Function (
): The component of a PDT (or FST) that specifies what output to write on each transition. means: in state , reading with stack top , write to the output tape. Defined only where is defined. - PDT Transition Label: Written as
(or ) on a diagram arrow, meaning: read from input, pop , push , write to output. - Closure Under an Operation: A class of languages
is closed under operation if for any , the result . Closed means: applying the operation stays within the class. - DPDA (Deterministic Pushdown Automaton): A PDA where each configuration has at most one possible next configuration:
for all , and implies . - Deterministic Context-Free Language (DCFL): A language recognized by some DPDA. The class of DCFLs is strictly contained within the class of CFLs.
- Acyclic PDA: A PDA in which, for every input string
, the computation always terminates — i.e., the PDA always reads the entire input and stops, with no -moves possible after all input is consumed. Every DPDA can be transformed into an equivalent acyclic DPDA. - Destructive Memory: The characteristic of a stack that once a symbol is popped, it is irrecoverably lost. Contrast with a read/write tape (Turing Machine) where symbols can be read without destroying them.
- Bar-Hillel Lemma (Pumping Lemma for CFLs): If
is a context-free language, then such that any with decomposes as with , , and for all . - Automata Theory: The branch of theoretical computer science studying abstract mathematical machines (automata) and the computational problems solvable by them.
- Model of Computation: A mathematical framework describing how outputs are computed from inputs, and how memory and computation are organized. Examples: FSAs, PDAs, Turing Machines, Lambda calculus, Petri nets.
- Turing Machine (TM): A model of computation with an infinite read/write tape. More powerful than PDAs because its memory is persistent — reading a cell does not erase it. The most general model of sequential computation.
- Context-Free Language (CFL): A language recognized by some (nondeterministic) pushdown automaton, or equivalently generated by a context-free grammar. The class of CFLs properly contains all regular languages.
3. Formulas
- PDT formal definition:
where and - PDT transition (input move):
when and - PDT transition (
-move): when and - PDT acceptance condition:
for some - Bar-Hillel Lemma: For CFL
, such that with , decomposition with , , and - Difference via complement:
(used to prove non-closure of DPDA under from non-closure under ) - De Morgan (set version):
(used to derive closure/non-closure results) - Closure summary for DPDA: closed under
only; NOT closed under , , or
4. Practice
4.1. Build a DPDT Translating to (Lab 7, Task 1)
Build a Deterministic Pushdown Transducer that accepts
Click to see the solution
Key Concept: Push one
States:
(reading ’s), (reading ’s, stack not yet empty), (reading excess ’s after stack is empty — accepting)Transitions:
From To Label Meaning Push , outputPush , outputFirst : pop , outputMore ’s: pop , outputStack empty: all ’s matched, enter excess phaseExcess ’s: discard (no output)Acceptance:
is accepting (after -move when stack holds only ). Also need , which is ensured because we must push at least one (no path to without going through ’s push phase).Trace for
(i.e., ):- Read
: push , output - Read
: push , output - Read
: pop , output - Read
: pop , output -move to (stack has )- Read
: discard, no output - End:
accepting. Output: . ✓
- Read
Answer:
4.2. Build a DPDT Reversing Strings in (Lab 7, Task 2)
Build a Deterministic Pushdown Transducer that recognizes
Click to see the solution
Key Concept: Use the stack’s LIFO property for reversal. Push every character of
States:
(push phase — reading ), (pop phase — reading and producing output), (accepting)Transitions:
From To Label Meaning Push , no outputPush , no outputPush below , no outputPush , no outputPush , no outputPush below , no outputSee : pop , outputSee : pop , outputPop , outputPop , outputStack empty: accept Trace for
( , ):- Push
(no output), push (no output) - Read
: pop , output -move: pop , output -move: see → accept. Output: . ✓
- Push
Answer:
4.3. Build a DPDT Translating to (Lab 7, Task 3)
Build a DPDT that accepts
Click to see the solution
Key Concept: Output
States:
(reading leading ), (reading ), (reading trailing ), (accepting)Transitions:
From To Label Meaning Leading : push , outputMore leading ’s: push , outputFirst : keep stack, outputMore ’s: output , don’t touch stackFirst trailing : pop , no outputMore trailing ’s: pop , no outputStack empty: all trailing ’s matched → acceptTrace for
:- Read
: push , output ; read : push , output - Read
, , : output , , (stack unchanged: ) - Read
: pop , no output; read : pop , no output -move: see → , accept. Output: . ✓
- Read
Answer:
4.4. Build a DPDT Translating to (Lab 7, Task 4)
Build a DPDT that accepts
Click to see the solution
Key Concept: The condition
Strategy:
- Push
for each (output ). - Match
’s against ’s (pop , output ) — after ’s, stack holds . - Continue reading
’s while pushing ’s (no output) — these are the “extra” ’s. - Match
’s against ’s (pop , no output) — output for each. - Accept when both
’s and ’s are matched.
- Push
States:
(reading ’s), (reading ’s, matching ’s), (reading extra ’s, pushing ’s), (reading ’s, matching ’s), (accepting)Transitions:
From To Label Meaning Push , outputPush , outputFirst : pop , outputMore ’s vs ’s: pop, outputStack empty ( ’s read): start extra ’sMore extra ’s: push , no outputFirst : pop , outputMore ’s: pop , outputAll matched: accept Trace for
( , and ✓):- Push
, output - Pop
, output ; pop , output (2 ’s matched ’s) - Push
, push (2 extra ’s) - Pop
, output ; pop , output (2 ’s) - See
→ accept. Output: . ✓
- Push
Answer:
4.5. Build a DPDT Translating to (Lab 7, Task 5)
Build a DPDT that accepts
Click to see the solution
Key Concept: The condition
A simpler approach: push two symbols per
- Push phase: For each
, push and (two markers). Output . - Pop phase: For each
, pop one marker. Output only for the first pops. - Accept when stack is empty (between
and ’s consumed).
Simplified transition design:
States:
Use stack symbols
| From | To | Label | Meaning |
|---|---|---|---|
| Push |
|||
| Push |
|||
| Push |
|||
| First |
|||
| More |
|||
| More |
|||
| Only |
|||
| All markers consumed: accept |
Answer:
4.6. DPDA Closure Under Complement — Construction Idea (Lecture 7, Example 1)
Explain why the class of DPDA languages is closed under complement, and outline the construction of the complement DPDA.
Click to see the solution
Key Concept: Complement of a DPDA language is computable by (1) making the DPDA acyclic, (2) completing its transition function, and (3) swapping accepting and non-accepting states.
- Why naive state-swapping fails: A DPDA on input
may end in a non-accepting state but then take an -move to reach accepting state . If we simply swap states, becomes accepting, so the “complement” DPDA also accepts — which is wrong (both accept , but they should have opposite behavior). - Step 1 — Eliminate loops (make acyclic): Transform the DPDA so that after consuming all input, no further
-moves are possible. This ensures the computation halts in a single well-defined state. Every DPDA can be equivalently expressed as an acyclic DPDA (proof omitted; it requires carefully removing -move cycles without changing the accepted language). - Step 2 — Complete
: Add a non-accepting “error” state and route all undefined transitions there. Now is a total function: every configuration has exactly one successor. - Step 3 — Swap accepting and non-accepting states: Since the machine is now acyclic and total, it always halts in exactly one state after reading the full input. Swapping
and correctly inverts the acceptance: strings that were accepted are now rejected, and vice versa. - Result: The complement DPDA recognizes
whenever the original DPDA recognizes . Therefore DPDA is closed under .
Answer: DPDA is closed under complement via the three-step construction: eliminate loops, complete
4.7. DPDA Closure Under Difference — Proof by Contradiction (Lecture 7, Example 2)
Prove that DPDA is not closed under set difference (
Click to see the solution
Key Concept: Use the identity
- Assume for contradiction that DPDA is closed under
. - Use the identity: For any sets
: - Apply closure assumptions:
- Since DPDA is closed under complement (proved):
. - By the assumed closure under difference:
and . - Therefore
for any .
- Since DPDA is closed under complement (proved):
- But: We proved that DPDA is not closed under intersection (using
). Contradiction! - Conclusion: The assumption was wrong. DPDA is not closed under
.
Answer: By contradiction using
4.8. DPDA Closure Under Union — Counterexample (Lecture 7, Example 3)
Show that the class of languages recognized by DPDAs is not closed under union, using
Click to see the solution
Key Concept: Both
- Verify
: Build a DPDA that pushes one per , then pops one per . Accepts when is on top after all ’s. Standard construction. - Verify
: Build a DPDA that pushes two ’s per , then pops one per . Accepts when is on top. - Argue
:- A DPDA reading
must decide in its stack preparation whether it will face or ’s. - After the
’s are read, the stack is committed. When the ’s arrive, the machine cannot re-examine the -count. - A deterministic machine cannot simultaneously prepare for both
’s and ’s. - A formal proof uses the fact that
(via Bar-Hillel Lemma) combined with algebraic manipulation.
- A DPDA reading
- Conclusion:
, so DPDA is not closed under .
Answer: DPDA is not closed under union. The union
4.9. FST — Translating All Strings Over (Tutorial 7, Example 1)
Build a Finite State Transducer that accepts any string
Click to see the solution
Key Concept: Since every string is accepted, a single accepting state with self-loops suffices.
- Define the FST components:
- States:
; initial state ; accepting: - Input alphabet:
; Output alphabet:
- States:
- Transitions (both are self-loops on
): : read , write : read , write
- Trace for input
:- Read
in : output , stay in - Read
in : output , stay in - Read
in : output , stay in - End of input;
→ accepted
- Read
Answer: Output
4.10. FST — Translating Only Strings Without ’s (Tutorial 7, Example 2)
Build a Finite State Transducer that accepts strings
Click to see the solution
Key Concept: Use a sink (non-accepting) state to handle
- States:
(accepting — no seen), (non-accepting sink — seen) - Transitions:
: read in , output , stay : read in , output , go to sink : read in sink, output nothing : read in sink, output nothing
- Trace for
: stays in , outputs → accepted, translation = - Trace for
: → rejected (translation undefined)
Answer: The FST has states
4.11. PDT — Translating (Tutorial 7, Example 3)
Build a Pushdown Transducer for
Click to see the solution
Key Concept: This translation requires a stack because we need to count
States:
(start), (reading ’s), (reading ’s), (accepting)Stack alphabet:
Transitions:
From To Label Meaning First : push , outputMore ’s: push , outputFirst : pop , outputMore ’s: pop , outputStack empty (only ): acceptTrace for
: (output ) (output ) (output ) (output ) — ACCEPT
Answer:
4.12. PDT — Translating (Tutorial 7, Example 4)
Build a Deterministic Pushdown Transducer for
Click to see the solution
Key Concept: During the push phase (reading
States:
(reading ’s), (reading ’s), (accepting)Transitions:
From To Label Meaning First : push , NO outputMore ’s: push , NO outputFirst : pop , outputMore ’s: pop , outputStack empty: accept, no output Trace for
(i.e., … but has 3 ’s and 2 ’s, not in ; use ):- Push
, push (no output), then pop (output ), pop (output ), see → accept. - Output:
.
- Push
Answer:
4.13. PDT — Translating (Tutorial 7, Example 5)
Build a DPDT for
Click to see the solution
Key Concept: Output
States:
(reading ’s), (reading ’s), (accepting)Transitions:
From To Label Meaning First : push , outputMore ’s: push , outputFirst : pop , outputMore ’s: pop , outputDone: accept Trace for
:- Read
: output , push - Read
: output , push - Read
: output , pop - Read
: output , pop - See
→ accept. Output: . ✓
- Read
Answer:
4.14. DPDA — Constructing the DPDA for (Tutorial 7, Example 6)
Build a DPDA that recognizes
Click to see the solution
Key Concept: Push
States:
(start), (reading ’s), (reading ’s), (reading ’s — accepting)Transitions:
From To Label Meaning First : pushMore ’s: pushFirst : popMore ’s: popFirst (stack shows , so ’s matched ’s): enter accepting phaseMore ’s: stayAcceptance:
is the accepting state; reached only when ’s exactly matched ’s and at least one was seen.
Answer: The DPDA with states
4.15. DPDA — Constructing the DPDA for (Tutorial 7, Example 7)
Build a DPDA that recognizes
Click to see the solution
Key Concept: Skip over the
States:
(start), (reading ’s), (reading ’s), (reading ’s), (accepting)Transitions:
From To Label Meaning First : no stack changeMore ’s: no stack changeFirst : pushMore ’s: pushFirst : popMore ’s: popStack has only : all ’s matched ’s → acceptAcceptance:
is accepting, reached via -move when stack shows .
Answer: The DPDA with states
4.16. DPDA Closure Under Intersection — Counterexample (Tutorial 7, Example 8)
Show that
Click to see the solution
Key Concept: Both
- Compute the intersection:
(A string belongs to both iff the -count equals the -count AND the -count equals the -count, so all three counts are equal.) - Apply Bar-Hillel Lemma to
: Assume it is a CFL. Let be the Bar-Hillel constant. Choose . Any decomposition with spans at most two of the three symbol groups. Pumping up ( ) increases only those two groups, making the counts unequal. Contradiction. So , and thus . - Conclusion:
but . Therefore DPDA is not closed under .
Answer: The intersection